# Contributor: Johannes Matheis <jomat+alpinebuild@jmt.gr>
# Maintainer: Johannes Matheis <jomat+alpinebuild@jmt.gr>
pkgname=quicktun
pkgver=2.2.4
pkgrel=5
pkgdesc="Simple and secure VPN software using NaCl encryption"
url="http://wiki.ucis.nl/QuickTun"
arch="all"
license="BSD"
depends=""
depends_dev=""
makedepends="$depends_dev linux-headers tar libsodium-dev"
install="quicktun.pre-install"
subpackages="$pkgname-keypair"
source="http://oss.ucis.nl/${pkgname}/src/${pkgname}-${pkgver}.tgz
	quicktun.initd
	quicktun.conf"

_builddir="$srcdir/${pkgname}-${pkgver}"
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	./build.sh
}

package() {
	cd "$_builddir"
	install -D out/quicktun.combined "${pkgdir}/usr/bin/quicktun.combined"
	ln -s quicktun.combined "${pkgdir}/usr/bin/quicktun"
	install -D -m600 ${srcdir}/quicktun.conf "${pkgdir}"/etc/quicktun/quicktun.conf
	install -D -m755 ${srcdir}/quicktun.initd "${pkgdir}"/etc/init.d/quicktun
}

keypair() {
	pkgdesc="Tool to create a quicktun public/private keypair"
	cd "$_builddir"
	install -D out/quicktun.keypair "${subpkgdir}/usr/bin/quicktun.keypair"
}

md5sums="5e27c9b1ccae0c6d6e4b30ca476f910d  quicktun-2.2.4.tgz
08544bcdaa8148041535e5622fad6008  quicktun.initd
097c43021134f43294c894464099a8fb  quicktun.conf"
sha256sums="652383d30f4a1ac2d42500e676f4c8590efaeea21a1e40a3ad1c332aa2ba3a0c  quicktun-2.2.4.tgz
185430ca6d9d27144d3e2b81edaa10f425c29b0a7d7296bdde322134cef3ca7f  quicktun.initd
787a37b2fbae6b44adebd422e6476da08c37c8db6bf0ac35a8d790ba4c50fe59  quicktun.conf"
sha512sums="da60fc39d8e85d5b2c162633840b887be3fd58d9f2b3a99fe605fa13546e4f53878ce6246d835b7931e42193fb044330c539b29751cdb6f54d025efc52041487  quicktun-2.2.4.tgz
3b9aa117800d23e84f4ac0ddfc37fe0499dc93514f72ab98d4cd315be201750f9acf2099268335a1774199d1f7310fc1b4c97f7ec7ba45740e9da5e0e89db959  quicktun.initd
6056ea4d4f8f8c58198a101b0f59f258e9318c3b57b6efbc6f3587665315b5b5990dee5662a27ee0e15a2333446c1d18b2a3650af7abbfbb4fe572c002b2a1b7  quicktun.conf"
